﻿CREATE PROCEDURE [dbo].[TempPIDifferences_SelectDuplicates]
AS
SELECT a.*
 FROM   TempPIDifferences As [a]
 INNER
  JOIN 
  (
	  SELECT ArticleId, StoreId, Date
	  FROM TempPIDifferences
	  GROUP BY ArticleId, StoreId, Date
	  HAVING COUNT(*) > 1
  ) As [b]
    ON a.ArticleId = b.ArticleId
   AND a.StoreId = b.StoreId
   AND a.Date = b.Date
  ORDER BY StoreId, Date, ArticleId